home *** CD-ROM | disk | FTP | other *** search
- Path: news.larc.nasa.gov!amiga-request
- From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
- Subject: v91i018: Mandel 1.0 - yet another mandelbrot, Part02/04
- Reply-To: dm@stekt.oulu.fi (Hannu Helminen ti)
- Newsgroups: comp.sources.amiga
- Message-ID: <comp.sources.amiga:v91i018@ab20.larc.nasa.gov>
- References: <comp.sources.amiga:v91i017@ab20.larc.nasa.gov>
- Date: 18 Feb 91 22:25:43 GMT
- Approved: tadguy@uunet.UU.NET (Tad Guy)
- X-Mail-Submissions-To: amiga@uunet.uu.net
- X-Post-Discussions-To: comp.sys.amiga.misc
-
- Submitted-by: dm@stekt.oulu.fi (Hannu Helminen ti)
- Posting-number: Volume 91, Issue 018
- Archive-name: applications/mandel-1.0/part02
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 2 (of 4)."
- # Contents: source/gui.asm.ab source/gui.asm.ac
- # Wrapped by tadguy@ab20 on Mon Feb 18 17:25:39 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'source/gui.asm.ab' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'source/gui.asm.ab'\"
- else
- echo shar: Extracting \"'source/gui.asm.ab'\" \(25782 characters\)
- sed "s/^X//" >'source/gui.asm.ab' <<'END_OF_FILE'
- X beq.s no_bl
- X move.w d2,d0
- X move.w d5,d1
- X Call DrawBorder
- Xno_bl:
- X move.l a4,a1
- X move.l a2,a0
- X move.l a1,pic_tr
- X beq.s no_tr
- X move.w d4,d0
- X move.w d3,d1
- X Call DrawBorder
- Xno_tr:
- X move.l a5,a1
- X move.l a2,a0
- X move.l a1,pic_br
- X beq.s no_br
- X move.w d4,d0
- X move.w d5,d1
- X Call DrawBorder
- Xno_br:
- X pull a3-a5
- X bra.s draw_pulling
- Xpig_big:
- X clr.l pic_tl
- X clr.l pic_bl
- X clr.l pic_tr
- X clr.l pic_br
- Xdraw_pulling:
- X pull a0-a2/a6/d0-d7
- Xdraw_over:
- X rts
- X
- Xcalculate:
- X* Calculate centerpoint coordinates.
- X* Only needed when string gadget updated.
- X* The formula we use is (CurrentX - mb_x(a4)) / mb_dx(a4) (for x)
- X* and because I would have to use 32-bit division which my processor
- X* does unfortunately not have any instructions for, we use 16-bit
- X* division, which is much more tricky!
- X
- X* Another problem occurs when user enters a number that is NOT
- X* in the visible area. Because our number system can only represent
- X* numbers from -4 to 4, we have no reliable way of telling whether
- X* user wants to see grid to be (arrows!) to the LEFT, for instance,
- X* or to the RIGHT.
- X
- X* Currently any such numbers map to RIGHT and DOWN. One could try
- X* to fix it by choosing numbers that are as close to previous prex
- X* and prey as possible.
- X* I wont try to code that, however, my hair is grey enough now.
- X
- X push d0-d4
- X move.l mb_dx(a4),d2
- X move.l CurrentX,d4
- X sub.l mb_x0(a4),d4
- Xfix_div_x:
- X cmp.l #$10000,d2
- X blo.s fixed_x
- X lsr.l #1,d2
- X lsr.l #1,d4
- X bra.s fix_div_x
- Xfixed_x:
- X divu d2,d4
- X move.l d4,d0 ; renormalize remainder
- X clr.w d0
- X divu d2,d0
- X swap d0
- X move.w d4,d0
- X
- X move.l mb_dy(a4),d2
- X move.l mb_y0(a4),d4
- X sub.l CurrentY,d4
- Xfix_div_y:
- X cmp.l #$10000,d2
- X blo.s fixed_y
- X lsr.l #1,d2
- X lsr.l #1,d4
- X bra.s fix_div_y
- Xfixed_y:
- X divu d2,d4
- X move.l d4,d1
- X clr.w d1
- X divu d2,d1
- X swap d1
- X move.w d4,d1
- X
- X swap d0
- X swap d1
- X
- X move.l d0,prex
- X move.l d1,prey
- X pull d0-d4
- X rts
- X
- XStringGadgetDown:
- X* GadgetID in d1
- X and.w #IDMASK,d1
- X
- X* We will wait for another message, thenafter we know the user has
- X* finished playing with the string gadget. This message could be the
- X* GADGETUP of same gadget, but then again, it could be something
- X* else.
- X* We must preserve the message (so that main loop may handle it).
- X move.l a5,a1 ; save gadget
- X bsr GetMessage
- X
- X move.l gg_SpecialInfo(a1),a0
- X move.l si_Buffer(a0),a0 ; addr of the actual string
- X
- X cmp.w #GAD_X,d1
- X beq.s gadget_x
- X cmp.w #GAD_Y,d1
- X beq.s gadget_y
- X cmp.w #GAD_M,d1
- X beq gadget_m
- X cmp.w #GAD_Z,d1
- X beq.s gadget_z
- X* now it must be IGadget
- X bsr GetNum
- X beq.s 2$
- X tst.b (a0)
- X beq.s 1$
- X2$:
- X move.w mb_i(a4),d0
- X1$: move.w d0,mb_i(a4)
- X bsr refresh_i
- X bra.s gadget_done
- X
- Xgadget_x:
- X bsr GetFixed
- X beq.s 2$
- X tst.b (a0) ; if user entered some ugly stuff after numbers
- X beq.s 1$
- X2$:
- X move.l CurrentX,d0 ; invalid -> get previous
- X1$: move.l d0,CurrentX
- X bsr calculate
- X bsr refresh_x
- X bsr DrawGrid
- X bra.s gadget_done
- X
- Xgadget_y:
- X bsr GetFixed
- X beq.s 2$
- X tst.b (a0)
- X beq.s 1$
- X2$:
- X move.l CurrentY,d0
- X1$: move.l d0,CurrentY
- X bsr calculate
- X bsr refresh_y
- X bsr DrawGrid
- X bra.s gadget_done
- X
- Xgadget_z:
- X bsr GetSMagnify
- X beq.s 2$
- X tst.b (a0)
- X beq.s 1$
- X2$:
- X move.l Zoom,d0
- X1$: move.l d0,Zoom
- X bsr refresh_z
- X bra.s gadget_done
- Xgadget_m:
- X bsr GetMagnify
- X beq.s 2$
- X tst.b (a0)
- X beq.s 1$
- X2$:
- X move.l Magnify,d0
- X1$: move.l d0,Magnify
- X bsr refresh_m
- X
- Xgadget_done:
- X moveq #0,d0
- X
- Xget_rid_of_us:
- X rts
- X
- X
- XOtherGadgetDown:
- X* GadgetID in d1
- X move.w d1,d0
- X and.w #ZOOMTYPE,d0
- X beq not_zoom_gadget
- X and.w #IDMASK,d1
- X
- X move.b #ZOOM,d0
- X cmp.w #GAD_ZOOM,d1
- X beq.s 1$
- X
- X move.b #REDRAW,d0
- X cmp.w #GAD_DRAW,d1
- X beq.s 1$
- X
- X move.b #RESET,d0
- X1$:
- X move.b d0,method
- X bsr refresh_zoom
- X* Double-click to start drawing
- X move.l OldSecs,d0
- X move.l OldMicros,d1
- X move.l a2,d2
- X move.l a3,d3
- X move.l a2,OldSecs
- X move.l a3,OldMicros
- X Call DoubleClick
- X tst.w d0
- X beq.s not_yet
- X moveq #-1,d0 ; result is negative
- Xnot_yet:
- X rts
- X
- Xnot_zoom_gadget:
- X move.w d1,d0
- X and.w #SETTYPE,d0
- X beq.s not_set_gadget
- X and.w #IDMASK,d1
- X
- X bclr.b #MBB_JULIA,mb_flags(a4)
- X cmp.w #GAD_MANDEL,d1
- X beq.s 1$
- X bset.b #MBB_JULIA,mb_flags(a4)
- X1$:
- X bsr refresh_set
- X
- X moveq #FALSE,d0
- X rts
- X
- Xnot_set_gadget:
- X cmp.w #GAD_QUIT,d1
- X bne.s not_quit_gadget
- X* Double-click to exit
- X move.l OldSecs,d0
- X move.l OldMicros,d1
- X move.l a2,d2
- X move.l a3,d3
- X move.l a2,OldSecs
- X move.l a3,OldMicros
- X Call DoubleClick
- X tst.w d0
- X beq.s first_click
- X moveq #TRUE,d0 ; +1 -> quitting
- Xfirst_click:
- X rts
- X
- Xnot_quit_gadget:
- X and.w #IDMASK,d1
- X moveq #0,d7
- X move.w d1,d7
- Xit_was_timer:
- X bsr plus_minus
- X lea IOreq,a1
- X
- X* Shortage of registers -- we must use upper half of d7
- X swap d7
- X move.l #400000,d0 ; .4 seconds initial delay
- X tst.w d7
- X beq.s huu_haa_joo_jaa
- X move.l #100000,d0 ; .1 seconds next 9
- X cmp.w #9,d7
- X blo.s huu_haa_joo_jaa
- X move.l #020000,d0 ; 1/25 seconds
- X move.w #-2,d7 ; neverending!
- Xhuu_haa_joo_jaa:
- X addq.w #1,d7
- X swap d7
- X
- X move.w #TR_ADDREQUEST,IO_COMMAND(a1)
- X move.l #0,IOTV_TIME+TV_SECS(a1)
- X move.l d0,IOTV_TIME+TV_MICRO(a1)
- X move.l a1,UseReq
- X Base Exec
- X Call SendIO
- X bsr GetMessage
- X bne.s 1$ ; that old ^C
- X cmp.w #FAKECLASS,d2
- X beq.s it_was_timer
- X moveq #FALSE,d7
- X bra.s 2$
- X1$:
- X moveq #TRUE,d7
- X2$:
- X move.l UseReq,a1
- X Call AbortIO
- X move.l UseReq,a1
- X Call WaitIO
- X clr.l UseReq
- X tst.w d7
- X rts
- X
- X moveq #0,d0
- X rts
- X
- Xplus_minus:
- X* GadgetID in d2
- X push d0-d1
- X move.w d7,d0
- X moveq #1,d1
- X and.w #$7fff,d0
- X cmp.w #GAD_X,d0
- X bne.s skip_x
- X
- X move.l mb_dx(a4),d0
- X swap d1
- X tst.w d7
- X bpl.s 1$
- X neg.l d0
- X neg.l d1
- X1$:
- X add.l d0,CurrentX
- X add.l d1,prex
- X move.l CurrentX,d0
- X bsr refresh_x
- X bsr DrawGrid
- X bra plus_minus_done
- Xskip_x:
- X cmp.w #GAD_Y,d0
- X bne.s skip_y
- X
- X move.l mb_dy(a4),d0
- X swap d1
- X tst.w d7
- X bpl.s 1$
- X neg.l d0
- X neg.l d1
- X1$:
- X add.l d0,CurrentY
- X sub.l d1,prey
- X move.l CurrentY,d0
- X bsr refresh_y
- X bsr DrawGrid
- X bra.s plus_minus_done
- Xskip_y:
- X cmp.w #GAD_M,d0
- X bne.s skip_m
- X
- X move.l #$1999,d0
- X tst.w d7
- X bpl.s 1$
- X neg.l d0
- X1$:
- X add.l d0,Magnify
- X move.l Magnify,d0
- X bsr refresh_m
- X bra.s plus_minus_done
- Xskip_m:
- X cmp.w #GAD_Z,d0
- X bne.s skip_z
- X
- X move.l #$1999,d0
- X tst.w d7
- X bpl.s 1$
- X neg.l d0
- X1$:
- X add.l d0,Zoom
- X move.l Zoom,d0
- X bsr refresh_z
- X bra.s plus_minus_done
- Xskip_z:
- X cmp.w #GAD_I,d0
- X bne.s plus_minus_done
- X
- X tst.w d7
- X bpl.s 1$
- X neg.l d1
- X1$:
- X add.w d1,mb_i(a4)
- X move.w mb_i(a4),d0
- X bsr refresh_i
- Xplus_minus_done:
- X pull d0-d1
- X rts
- X
- X
- X
- X* This group of routines updates whatever visual clues the user might
- X* have about the current situation.
- X
- X* NOTE: a DrawGrid is needed after every refresh_x or refresh_y.
- X* (To avoid drawing it twice if both coords updated)
- X
- X* d0 is the fresh number.
- X* Preserves all registers.
- Xrefresh_x:
- X push d0-d2/d7/a0-a3/a6
- X move.l MyWindow2,a2 ; save thing from being overwritten
- X lea XGadget,a3
- X* If in MANDEL mode, alter c = jx + jy settings.
- X* So user may set jx,jy, enter JULIA mode and still
- X* select another point.
- X btst.b #MBB_JULIA,mb_flags(a4)
- X bne.s 1$
- X move.l d0,mb_jx(a4)
- X1$:
- X move.l d0,d2
- X
- X move.l a2,a0 ; window
- X move.l a3,a1 ; gadget
- X Base Intuition
- X Call RemoveGadget ; remove, modify, add back.
- X* Later we will insert this gadget back to its original place.
- X* That is why d2 gets position. toDec needs number in d0.
- X exg.l d0,d2
- X
- X move.l gg_SpecialInfo(a3),a0
- X move.l si_Buffer(a0),a0
- X
- X move.l mb_dx(a4),d7 ; delta (see toDec why)
- X bsr toDec
- X clr.b (a0)
- X
- X bsr refresh_add_gadget
- X pull d0-d2/d7/a0-a3/a6
- X rts
- Xrefresh_y:
- X push d0-d2/d7/a0-a3/a6
- X move.l MyWindow2,a2 ; save things from being overwritten
- X lea YGadget,a3
- X
- X btst.b #MBB_JULIA,mb_flags(a4)
- X bne.s 1$
- X move.l d0,mb_jy(a4)
- X1$:
- X move.l d0,d2
- X
- X move.l a2,a0 ; window
- X move.l a3,a1 ; gadget
- X Base Intuition
- X Call RemoveGadget ; remove, modify, add back.
- X
- X exg.l d0,d2
- X
- X move.l gg_SpecialInfo(a3),a0
- X move.l si_Buffer(a0),a0
- X
- X move.l mb_dy(a4),d7 ; delta (see toDec why)
- X bsr toDec
- X clr.b (a0)
- X
- X bsr refresh_add_gadget
- X pull d0-d2/d7/a0-a3/a6
- X rts
- Xrefresh_z:
- X push d0-d2/a0-a3/a6
- X move.l MyWindow2,a2 ; save thing from being overwritten
- X lea ZGadget,a3
- X move.l d0,d2
- X
- X move.l a2,a0 ; window
- X move.l a3,a1 ; gadget
- X Base Intuition
- X Call RemoveGadget ; remove, modify, add back.
- X* Later we will insert this gadget back to its original place.
- X* That is why d2 gets position. toDec needs number in d0.
- X exg.l d0,d2
- X
- X move.l gg_SpecialInfo(a3),a0
- X move.l si_Buffer(a0),a0
- X
- X move.b #'+',d1
- X tst.l d0
- X bpl.s 1$
- X neg.l d0
- X move.b #'-',d1
- X1$:
- X move.b d1,(a0)+
- X
- X bsr toMag
- X clr.b (a0)
- X
- X bsr refresh_add_gadget
- X
- X cmp.b #REDRAW,method
- X bne.s 2$
- X move.l OldMagnify,d0
- X move.l d0,Magnify
- X bsr refresh_m ; to show magnify is again normal
- X move.b #ZOOM,method ; NOTE: this must be AFTER refresh_m
- X bsr refresh_zoom ; does also DrawGrid
- X bra.s 3$ ; so dont waste time doing it again
- X2$:
- X bsr DrawGrid
- X3$:
- X pull d0-d2/a0-a3/a6
- X rts
- Xrefresh_i:
- X push d0-d2/a0-a3/a6
- X move.l MyWindow2,a2 ; save thing from being overwritten
- X lea IGadget,a3
- X move.l d0,d2
- X
- X move.l a2,a0 ; window
- X move.l a3,a1 ; gadget
- X Base Intuition
- X Call RemoveGadget ; remove, modify, add back.
- X* Later we will insert this gadget back to its original place.
- X* That is why d2 gets position. toDec needs number in d0.
- X exg.l d0,d2
- X
- X move.l gg_SpecialInfo(a3),a0
- X move.l si_Buffer(a0),a0
- X
- X bsr toInt
- X clr.b (a0)
- X
- X bsr.s refresh_add_gadget
- X pull d0-d2/a0-a3/a6
- X rts
- Xrefresh_m:
- X push d0-d2/a0-a3/a6
- X move.l MyWindow2,a2 ; save thing from being overwritten
- X lea MGadget,a3
- X move.l d0,d2
- X
- X move.l a2,a0 ; window
- X move.l a3,a1 ; gadget
- X Base Intuition
- X Call RemoveGadget ; remove, modify, add back.
- X* Later we will insert this gadget back to its original place.
- X* That is why d2 gets position. toDec needs number in d0.
- X exg.l d0,d2
- X
- X move.l gg_SpecialInfo(a3),a0
- X move.l si_Buffer(a0),a0
- X
- X bsr toMag
- X clr.b (a0)
- X
- X bsr.s refresh_add_gadget
- X
- X cmp.b #ZOOM,method
- X bne.s 1$
- X move.b #REDRAW,method
- X bsr refresh_zoom ; does also DrawGrid,
- X bra.s 2$ ; so dont repeat it.
- X1$:
- X bsr DrawGrid
- X2$:
- X pull d0-d2/a0-a3/a6
- X rts
- X
- X* This is common to all above.
- Xrefresh_add_gadget:
- X move.l gg_SpecialInfo(a3),a0
- X clr.w si_BufferPos(a0)
- X clr.w si_DispPos(a0)
- X move.l a2,a0 ; window
- X move.l a3,a1 ; gadget
- X move.l d2,d0 ; the very same position
- X Call AddGadget
- X move.l a3,a0 ; gadget
- X move.l a2,a1 ; window
- X sub.l a2,a2 ; "requester / no requester"
- X moveq #1,d0
- X Call RefreshGList ; actually just one
- X rts
- X
- X* Hah haa! Still more refreshing routines:
- X
- Xrefresh_set:
- X push d0-d2/a0-a3/a5/a6
- X Base Intuition
- X move.l MyWindow2,a0
- X move.l a0,a5
- X lea MANDELGadget,a1
- X move.l a1,a3
- X moveq #2,d0
- X Call RemoveGList
- X
- X lea JULIAGadget,a1
- X btst.b #MBB_JULIA,mb_flags(a4)
- X beq.s it_is_mandel
- X
- X or.w #SELECTED,gg_Flags(a1)
- X and.w #~SELECTED,gg_Flags(a3)
- X bra.s put_them_back
- Xit_is_mandel:
- X and.w #~SELECTED,gg_Flags(a1)
- X or.w #SELECTED,gg_Flags(a3)
- Xput_them_back:
- X move.l a5,a0 ; window
- X move.l a3,a1 ; gadget
- X sub.l a2,a2 ; requester
- X ; d0 is all right (RemoveGList...)
- X moveq #2,d1
- X Call AddGList
- X
- X move.l a3,a0 ; gadget
- X move.l a5,a1 ; window
- X ; a2 is still 0. (Dunno if it should be 0 anyway?)
- X moveq #2,d0
- X Call RefreshGList
- X
- X pull d0-d2/a0-a3/a5/a6
- X rts
- X
- Xrefresh_zoom:
- X push d0-d2/a0-a3/a5/a6
- X Base Intuition
- X move.l MyWindow2,a0
- X move.l a0,a5
- X lea ZOOMGadget,a1
- X move.l a1,a3
- X moveq #3,d0
- X Call RemoveGList
- X
- X lea DRAWGadget,a2
- X lea RESETGadget,a1
- X
- X move.b method,d1
- X cmp.b #REDRAW,d1
- X beq.s it_is_draw
- X cmp.b #RESET,d1
- X beq.s it_is_reset
- X
- X or.w #SELECTED,gg_Flags(a3) ; zoom
- X and.w #~SELECTED,gg_Flags(a2)
- X and.w #~SELECTED,gg_Flags(a1)
- X bra.s complex_and_unique_label
- Xit_is_draw:
- X and.w #~SELECTED,gg_Flags(a3)
- X or.w #SELECTED,gg_Flags(a2) ; draw
- X and.w #~SELECTED,gg_Flags(a1)
- X bra.s complex_and_unique_label
- Xit_is_reset:
- X and.w #~SELECTED,gg_Flags(a3)
- X and.w #~SELECTED,gg_Flags(a2)
- X or.w #SELECTED,gg_Flags(a1) ; reset
- Xcomplex_and_unique_label:
- X move.l a5,a0 ; window
- X move.l a3,a1 ; gadget
- X sub.l a2,a2 ; requester
- X ; d0 is all right (RemoveGList...)
- X moveq #3,d1
- X Call AddGList
- X
- X move.l a3,a0 ; gadget
- X move.l a5,a1 ; window
- X ; a2 is still 0. (Dunno if it should be 0 anyway?)
- X moveq #3,d0
- X Call RefreshGList
- X
- X pull d0-d2/a0-a3/a5/a6
- X bsr DrawGrid ; if something changed, show it.
- X rts
- X
- X
- XGetSMagnify:
- X move.b (a0)+,d0
- X cmp.b #'+',d0
- X beq.s 1$
- X cmp.b #'-',d0
- X beq.s 2$
- X subq.l #1,a0
- X1$:
- X bsr GetMagnify
- X rts
- X2$:
- X bsr GetMagnify
- X beq.s 3$
- X neg.l d0
- X3$:
- X rts
- X
- XRightButton:
- X clr.b method ; == move.b #ZOOM,method
- X ; so RMB is a shorthand for ZOOM
- X bsr refresh_zoom
- X move.w d5,d0
- X move.w d6,d1
- X
- X push d5/d6
- X swap d5
- X swap d6
- X clr.w d5
- X clr.w d6
- X bsr refresh_pos
- X pull d5/d6
- X
- X* a few words of explanation:
- X* Because we cannot process MOUSEMOVE events fast enough, we do
- X* the following: Loop CheckMessage, saving d5/d6 each turn,
- X* until it returns event that isn't of class MOUSEMOVE.
- X* Then process saved d5/d6 (they represent the position mouse was
- X* in BEFORE this message arrived).
- X* If message is of class NULL (no messages), start it all again.
- X
- Xrightloop:
- X move.w d5,tmpx
- X move.w d6,tmpy
- X push d0-d1
- X bsr CheckMessage
- X pull d0-d1
- X bne do_the_wrong_thing
- X
- Xwe_have_already_got_one:
- X cmp.l #MOUSEMOVE,d2
- X beq.s rightloop
- X
- X push d0-d2/d5/d6 ; so as not to trash current message
- X
- X* Uh oh... When I thought it would be nice if user could use
- X* magnification instead of deltas, I knew I would have to
- X* code 2^(-mag) in mach lang. But it never occured to me that
- X* I would have to code log2 somewhere....
- X* There is only one word to describe this: disqusting
- X push d0/d1 ; again!
- X sub.w tmpx,d0
- X bpl.s notneg1
- X neg.w d0
- Xnotneg1:
- X sub.w tmpy,d1
- X bpl.s notneg2
- X neg.w d1
- Xnotneg2:
- X bne.s r_isnonzero
- X tst.w d0
- X beq.s r_iszero
- Xr_isnonzero:
- X move.w mb_x2(a4),d2
- X sub.w mb_x1(a4),d2
- X swap d0
- X clr.w d0
- X divu d2,d0
- X bvc.s no_overf_1
- X moveq #-1,d0
- Xno_overf_1:
- X move.w mb_y2(a4),d2
- X sub.w mb_y1(a4),d2
- X swap d1
- X clr.w d1
- X divu d2,d1
- X bvc.s no_overf_2
- X moveq #-1,d1
- Xno_overf_2:
- X cmp.w d1,d0
- X bhi.s d0_is_higher
- X move.w d1,d0
- Xd0_is_higher:
- X bsr log2 ; I will code it later, ok?
- X move.l d0,Zoom
- Xr_iszero:
- X pull d0/d1
- X move.w tmpx,d5
- X move.w tmpy,d6
- X add.w d0,d5
- X add.w d1,d6
- X swap d5
- X swap d6
- X clr.w d5
- X clr.w d6
- X
- X move.l mb_dx(a4),d1
- X move.l mb_dy(a4),d2
- X lsr.l #1,d1
- X lsr.l #1,d2
- X
- X lsr.l #1,d5
- X tst.w d5
- X bmi.s 1$
- X moveq #0,d1
- X1$:
- X lsr.l #1,d6
- X tst.w d6
- X bmi.s 2$
- X moveq #0,d2
- X2$:
- X move.l d5,prex
- X move.l d6,prey
- X swap d5
- X swap d6
- X bsr Position
- X add.l d1,d5
- X sub.l d2,d6
- X move.l d5,CurrentX
- X move.l d6,CurrentY
- X move.l d5,d0
- X bsr refresh_x
- X move.l d6,d0
- X bsr refresh_y
- X move.l Zoom,d0
- X bsr refresh_z ; This will do DrawGrid also.
- X pull d0-d2/d5/d6
- X tst.l d2
- X bne.s exit_right_button ; probably MENUUP
- X
- X* How cute!!! LOVELY!!! Even here, this proggie refuses to busywait!!!!
- X bsr GetMessage ; (ya see, no CheckMessage!)
- X bne.s do_the_wrong_thing
- X cmp.l #MOUSEMOVE,d2
- X bne.s exit_right_button
- X move.w d5,tmpx
- X move.w d6,tmpy
- X bra we_have_already_got_one
- X
- Xexit_right_button:
- X moveq #0,d0
- Xdo_the_wrong_thing:
- X rts
- X
- Xrefresh_pos:
- X push d0
- X move.l d5,prex
- X move.l d6,prey
- X swap d5
- X swap d6
- X bsr Position
- X move.l d5,CurrentX
- X move.l d6,CurrentY
- X move.l d5,d0
- X bsr refresh_x
- X move.l d6,d0
- X bsr refresh_y
- X bsr DrawGrid
- X pull d0
- X rts
- X
- XLeftButton:
- X move.l OldSecs,d0
- X move.l OldMicros,d1
- X move.l a2,d2
- X move.l a3,d3
- X move.l a2,OldSecs
- X move.l a3,OldMicros
- X Call DoubleClick
- X tst.w d0
- X bne.s left_double
- X
- X* We use a loop similar to RightButton's.
- Xleftloop
- X move.w d5,tmpx
- X move.w d6,tmpy
- X bsr CheckMessage
- X bne left_aborted ; ^C
- Xleft_gotmessage
- X cmp.l #MOUSEMOVE,d2
- X beq.s leftloop
- X
- X push d5/d6
- X swap d5
- X swap d6
- X clr.w d5
- X clr.w d6
- X bsr refresh_pos
- X pull d5/d6
- X
- X tst.l d2
- X bne.s left_exit ; probably SELECTUP
- X
- X bsr GetMessage
- X bne.s left_aborted
- X cmp.l #MOUSEMOVE,d2
- X bne.s left_exit
- X move.w d5,tmpx
- X move.w d6,tmpy
- X bra left_gotmessage
- Xleft_exit
- X moveq #FALSE,d0 ; return zero
- X bra.s left_return
- Xleft_double
- X swap d5
- X swap d6
- X clr.w d5
- X clr.w d6
- X bsr refresh_pos
- X moveq #TRUE,d0 ; return positive nonzero
- X bra.s left_return
- Xleft_aborted
- X moveq #-TRUE,d0 ; return negative nonzero
- Xleft_return
- X rts
- X
- X
- X* Converts an integer from d0.w to a string (a0)+.
- X* Grr.. Why don't we have most significant digit last?
- XtoInt:
- X push d0-d2
- X move.w #10000,d1
- X moveq #FALSE,d2
- X1$:
- X and.l #$ffff,d0
- X divu d1,d0
- X bne.s 4$
- X tst.w d2 ; discard leading zeros
- X beq.s 2$
- X4$:
- X add.b #'0',d0
- X move.b d0,(a0)+
- X moveq #TRUE,d2
- X2$:
- X swap d0
- X ext.l d1
- X divu #10,d1
- X bne.s 1$
- X
- X tst.w d2
- X bne.s 3$
- X move.b #'0',(a0)+ ; if d0=0, display at least a 0.
- X3$:
- X pull d0-d2
- X rts
- X
- X* Still one more conversion routine. (for Magnify's internal format)
- XtoMag:
- X push d0-d2
- X move.l d0,d1
- X swap d0
- X bsr.s toInt
- X move.b #'.',(a0)+
- X
- X moveq #3,d2
- X1$:
- X mulu #10,d1
- X swap d1
- X add.b #'0',d1
- X move.b d1,(a0)+
- X swap d1
- X dbf d2,1$
- X
- X tst.w d1
- X bpl.s 2$ ; if < $8000, no rounding needed
- X bsr Round
- X2$:
- X pull d0-d2
- X rts
- X
- X
- XdispCoords:
- X* This routine displays the coordinates of current mouse position
- X* in screen title bar.
- X bsr.s Position
- X lea CoordText,a0
- X move.l d5,d0
- X move.l mb_dx(a4),d7
- X bsr.s toDec
- X move.b #' ',(a0)+
- X move.l d6,d0
- X move.l mb_dy(a4),d7
- X bsr.s toDec
- X clr.b (a0)+
- X* There was a time when I used SetWindowTitles here.
- X* But the flashing... and the speed (or rather lack of)...
- X
- X move.l MyScreen,a0
- X lea sc_RastPort(a0),a0
- X lea Coords,a1
- X moveq #80,d0
- X moveq #0,d1
- X Call PrintIText
- X
- X rts
- X
- X* Fetch absolute position in complex plane when d5/d6 has
- X* mouse position. Return result also in d5/d6.
- XPosition:
- X push d0
- X move.w d5,d0
- X mulu mb_dx(a4),d5
- X swap d5
- X clr.w d5
- X mulu 2+mb_dx(a4),d0
- X add.l d0,d5
- X add.l mb_x0(a4),d5
- X
- X move.w d6,d0
- X mulu mb_dy(a4),d6
- X swap d6
- X clr.w d6
- X mulu 2+mb_dy(a4),d0
- X add.l d0,d6
- X neg.l d6
- X add.l mb_y0(a4),d6
- X pull d0
- X
- X rts
- X
- X* toDec is the reverse of GetFixed. I will use a couple look-up tables
- X* here, too.
- X* INPUTS fixed point in d0, buffer in a0, delta in d7.
- X* RETURN next a0 in a0.
- X
- XtoDec:
- X push a1-a3/d0-d6
- X move.b #'+',d2
- X tst.l d0
- X bpl.s 1$
- X
- X move.b #'-',d2
- X neg.l d0
- X1$: move.b d2,(a0)+
- X
- X move.b #'0',d2
- X3$: cmp.l #$20000000,d0
- X blo.s 2$
- X sub.l #$20000000,d0
- X addq.b #1,d2
- X bra.s 3$
- END_OF_FILE
- if test 25782 -ne `wc -c <'source/gui.asm.ab'`; then
- echo shar: \"'source/gui.asm.ab'\" unpacked with wrong size!
- fi
- # end of 'source/gui.asm.ab'
- fi
- if test -f 'source/gui.asm.ac' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'source/gui.asm.ac'\"
- else
- echo shar: Extracting \"'source/gui.asm.ac'\" \(26047 characters\)
- sed "s/^X//" >'source/gui.asm.ac' <<'END_OF_FILE'
- X2$:
- X move.b d2,(a0)+
- X move.b #'.',(a0)+
- X
- X lea 4+NumberHi,a1
- X lea 4+NumberLo,a2
- X move.l #-1,a3 ; for precision determining.
- X moveq #0,d1 ; use 64 bits of precision (SHIT! why?)
- Xouterloop:
- X move.b #'0',d2
- X move.l (a1)+,d3
- X move.l (a2)+,d4
- Xinnerloop:
- X move.l d0,d5
- X move.l d1,d6
- X sub.l d4,d6
- X subx.l d3,d5
- X bmi.s below0
- X move.l d5,d0
- X move.l d6,d1
- X addq.b #1,d2
- X bra.s innerloop
- Xbelow0:
- X cmp.l a3,d7
- X move.l -4(a1),a3
- X bhi.s it_is_over ; it sayz: being too accurate
- X move.b d2,(a0)+
- X bra.s outerloop
- Xit_is_over:
- X
- X* Now we round the number. This was added because it was frustrating
- X* when user entered, say, 0.7 and got back 0.69.
- X* This is an ascii round.
- X cmp.b #'5',d2
- X blo.s no_round
- X bsr.s Round
- X
- Xno_round:
- X pull a1-a3/d0-d6
- X rts
- X
- X* This is an ASCII round.
- XRound: push a0/d0
- X1$: move.b -(a0),d0
- X cmp.b #'.',d0
- X beq.s 1$
- X cmp.b #'9',d0
- X bne.s 2$
- X move.b #'0',(a0)
- X bra.s 1$
- X2$:
- X addq.b #1,(a0)
- X pull a0/d0
- X rts
- X
- X* Wait() for an IDCMP message from either of the windows,
- X* or timer I/O to complete.
- X* Handle ^C explicitely.
- X
- XGetMessage:
- X push d0-d1/a0-a1
- X
- Xtest_messages:
- X bsr CheckMessage
- X bne.s found_one ; of class ^C
- X tst.l d2 ; which class? (0 = none found)
- X bne.s set_Z_exit
- X
- X* No messages. Wait for them.
- X bset #SIGBREAKB_CTRL_C,d0
- X Base Exec
- X Call Wait
- X btst #SIGBREAKB_CTRL_C,d0
- X bne.s found_one ; ^C (return with Z clear)
- X
- X bra.s test_messages ; Now there's a message for us. Fetch it.
- Xset_Z_exit:
- X moveq #0,d0
- Xfound_one:
- X pull d0-d1/a0-a1
- X rts
- X
- X* This routine just gets a message if it IS here, but does not
- X* Wait() for it. However, returns with signal mask in d0 if
- X* caller wishes to wait.
- X
- XCheckMessage:
- X* Test if any messages arrived
- X Base Exec
- X moveq #0,d2 ; Signal mask
- X
- X* First window
- X move.l MyWindow1,a0 ; This is always open
- X move.l wd_UserPort(a0),a0
- X move.b MP_SIGBIT(a0),d0
- X bset d0,d2
- X Call GetMsg
- X tst.l d0
- X bne.s foundmsg
- X
- X* Second window
- X move.l MyWindow2,a0
- X move.l a0,d0
- X beq.s 1$ ; check if open
- X move.l wd_UserPort(a0),a0
- X move.b MP_SIGBIT(a0),d0
- X bset d0,d2
- X Call GetMsg
- X tst.l d0
- X bne.s foundmsg
- X1$:
- X* Timer I/O
- X move.l UseReq,a1
- X move.l a1,d0
- X beq.s 2$ ; no request pending
- X move.l MN_REPLYPORT(a1),a0
- X move.b MP_SIGBIT(a0),d0
- X bset d0,d2
- X Call CheckIO
- X tst.l d0
- X bne.s foundio
- X2$:
- X* No messages! Return with 0 in d2, signal set in d0.
- X exg.l d0,d2
- X rts
- X
- Xfoundmsg:
- X move.l d0,a1
- X move.l im_Class(a1),d2
- X move.w im_Code(a1),d3
- X move.w im_Qualifier(a1),d4
- X move.l im_IAddress(a1),a5
- X move.w im_MouseX(a1),d5
- X move.w im_MouseY(a1),d6
- X move.l im_Seconds(a1),a2
- X move.l im_Micros(a1),a3
- X Call ReplyMsg
- X cmp.l #RAWKEY,d2
- X bne.s nobreak
- X cmp.w #$33,d3 ; RAW keycode for 'c'
- X bne.s nobreak
- X btst #IEQUALIFIERB_CONTROL,d4
- X beq.s nobreak
- Xbreak:
- X moveq #TRUE,d0
- X rts
- Xfoundio:
- X move.l UseReq,a1
- X Call WaitIO
- X clr.l UseReq
- X moveq #FAKECLASS,d2
- Xnobreak:
- X moveq #FALSE,d0
- X rts
- X
- XTransform:
- X* Firsty: Magnify is useless to brot. Need to calculate
- X* 2 ^ (-Magnify). That, again, is very very inconvenient.
- X
- X* Lets do it in a subroutine. Someone else might need it.
- X move.w #$2000,d0
- X moveq #$0000,d1 ; d0/d1 form 1 (fixed),
- X moveq #$0000,d2 ; d2 is just extension
- X move.l Magnify,d3
- X bsr.s Power2
- X
- X ifeq SCREEN-0
- X move.l d0,mb_dx(a4)
- X move.l d0,mb_dy(a4)
- X endc
- X ifeq SCREEN-1
- X asr.l #1,d0
- X move.l d0,mb_dx(a4)
- X asl.l #1,d0
- X move.l d0,mb_dy(a4)
- X endc
- X ifeq SCREEN-2
- X asr.l #1,d0
- X move.l d0,mb_dy(a4)
- X asl.l #1,d0
- X move.l d0,mb_dx(a4)
- X endc
- X ifeq SCREEN-3
- X asr.l #1,d0
- X move.l d0,mb_dx(a4)
- X move.l d0,mb_dy(a4)
- X endc
- X
- X* 'brot' expects to see z = x0 + y0 i to be upper lefthand corner
- X* whereas this program has until now assumed it is centerpoint.
- X* I wont use mulX instructions here because we are not in such a
- X* hurry. And secondly, on low magnification levels this is more
- X* accurate. (OK, that sounded nice. The real reason was that
- X* I am too lazy to find out what was wrong with that mulu!)
- X
- X move.w mb_x1(a4),d0
- X add.w mb_x2(a4),d0
- X move.l CurrentX,d1
- X move.l mb_dx(a4),d2
- X lsr.w #1,d0
- X bcc.s 1$
- X
- X move.l d2,d3
- X asr.l #1,d3
- X sub.l d3,d1
- X1$:
- X tst.w d0
- X beq.s 2$
- X sub.l d2,d1
- X subq.w #1,d0
- X bra.s 1$
- X2$: move.l d1,mb_x0(a4)
- X
- X move.w mb_y1(a4),d0
- X add.w mb_y2(a4),d0
- X move.l CurrentY,d1
- X move.l mb_dy(a4),d2
- X lsr.w #1,d0
- X bcc.s 3$
- X
- X move.l d2,d3
- X asr.l #1,d3
- X add.l d3,d1
- X3$:
- X tst.w d0
- X beq.s 4$
- X add.l d2,d1
- X subq.w #1,d0
- X bra.s 3$
- X4$: move.l d1,mb_y0(a4)
- X
- X rts
- X
- XPower2:
- X* I must be a masochist...
- X* Right now I have no idea how to code this routine. Hm. let's see.
- X
- X* This routine should be called with Magnify (or Zoom) in d3.
- X* d0/d1/d2 should be set to value to be multiplied by 2^(-d3).
- X* Returns d0.
- X
- X push d1-d4/a0
- X
- X* I seem to break the calculation into smaller ones, like
- X* 2^(-1) x 2^(-1) x ... x 2^(-1) x 2^(-1/2) x 2^(-1/4) x ...
- X* Each bit corresponds to one multiplication.
- X
- X swap d3
- X tst.w d3
- Xminusone:
- X beq.s skip_power
- X lsr.w #1,d0 ; This is x 2^(-1)
- X roxr.w #1,d1
- X roxr.w #1,d2
- X subq.w #1,d3
- X bra.s minusone
- Xskip_power:
- X
- X swap d3
- X lea NumberP,a0
- Xminusfrac:
- X move.w (a0)+,d4
- X asl.w #1,d3
- X bcc.s dont_multi
- X
- X mulu d4,d0
- X mulu d4,d1
- X mulu d4,d2
- X swap d2
- X add.w d1,d2
- X swap d1
- X addx.w d0,d1
- X swap d0
- X moveq #0,d4
- X addx.w d4,d0
- Xdont_multi:
- X tst.w d3
- X bne minusfrac
- X
- X* Ha! It was easy!
- X swap d0
- X move.w d1,d0
- X
- X pull d1-d4/a0
- X rts
- X
- X* Oooooh how I wish I had a C-compiler!
- X* Inverse of Power2, that is,
- X* log ( d2 ) in zoom/magnify fixed point format.
- X* 2
- Xlog2:
- X push d1-d4/a0
- X moveq #0,d1 ; this gets the answer
- Xlog_int:
- X tst.w d0
- X bmi.s log_frac
- X addq.w #1,d1
- X lsl.w #1,d0
- X bra.s log_int
- Xlog_frac:
- X swap d1
- X lea NumberL,a0
- X moveq #15,d2
- Xlog_loop:
- X lsl.w #1,d1 ; go through 16 bits
- X move.w (a0)+,d3
- X moveq #0,d4
- X move.w d0,d4
- X swap d4
- X mulu d0,d3
- X add.l d3,d4
- X bcs.s log_overflow
- X* That multiplication was "valid" -> record intermediate result
- X* in d0. Bit in d1 collects final result.
- X or.b #1,d1
- X swap d4
- X bpl.s 1$
- X add.w #1,d4
- X1$:
- X move.w d4,d0
- Xlog_overflow:
- X dbf d2,log_loop
- X move.l d1,d0
- X pull d1-d4/a0
- X
- X* AMAZING! UNBELIEVABLE! I think I got it right THE VERY FIRST TIME
- X* I CODED IT! This must have been the 1st routine that didnt
- X* need to be debugged! And I thought this would be hard...
- X
- X rts
- X
- X
- XCtrlC:
- X push a0-a1/d0-d1/a6
- X Base Exec
- X move.l MyWindow1,a0
- X move.l wd_UserPort(a0),a0
- X Call GetMsg
- X tst.l d0
- X beq.s no_c
- X move.l d0,a1
- X cmp.l #RAWKEY,im_Class(a1)
- X bne.s reply_c
- X cmp.w #$33,im_Code(a1)
- X bne.s reply_c
- X move.w im_Qualifier(a1),d0
- X btst #IEQUALIFIERB_CONTROL,d0
- X beq.s reply_c
- X Call ReplyMsg
- X moveq #-1,d0
- X bra.s exit_c
- Xreply_c:
- X Call ReplyMsg
- Xno_c:
- X moveq #0,d0
- X moveq #0,d1
- X Call SetSignal
- X btst #SIGBREAKB_CTRL_C,d0
- Xexit_c:
- X pull a0-a1/d0-d1/a6
- X rts
- X
- X
- X
- X* This routine gets decimal number ( -4.0 .. 4.0 ) from (a0)+ to d0.
- X* Format is fixed point.
- X
- X* If Z bit is set (indicating zero result) no number was found.
- X
- X* This may be one of the stupidest routines I've written. But
- X* it doesnot matter. This way I will always be accurate enough.
- X* (For those meatheads that do not understand what I mean:
- X* I use internally 64 bits of precision, the final result
- X* will have only 32...)
- X
- XGetFixed:
- X push a1-a3/d1-d5
- X move.l a0,a3
- X moveq #0,d1
- X moveq #0,d3
- X move.l #$80000000,d2
- X lea NumberHi,a1
- X lea NumberLo,a2
- X1$:
- X move.b (a0)+,d0
- X cmp.b #'+',d0
- X beq.s 1$
- X cmp.b #'-',d0
- X bne.s 2$
- X bset #15,d3 ; Now this is negative
- X bra.s 1$
- X2$:
- X cmp.b #'.',d0
- X bne.s 3$
- X bset #7,d3 ; Remember: now we have gone past
- X bra.s 1$
- X3$:
- X cmp.b #'0',d0
- X blo.s 4$
- X cmp.b #'9',d0
- X bhi.s 4$
- X
- X bset #0,d3
- X cmp.l (a1)+,(a2)+ ; go to next number position
- X tst.b d3
- X bmi.s 5$
- X lea NumberHi,a1 ; We will patiently stuck with these until
- X lea NumberLo,a2 ; decimal point found
- X5$:
- X sub.b #'0'+1,d0
- X bmi.s 1$
- X ext.w d0
- X move.l (a1),d4
- X move.l (a2),d5
- X6$:
- X add.l d5,d2
- X addx.l d4,d1
- X dbf d0,6$
- X bra.s 1$
- X
- X4$:
- X subq.l #1,a0
- X bsr.s SkipBlk
- X tst.w d3
- X bpl.s 7$
- X neg.l d1
- X7$:
- X move.l d1,d0
- X btst #0,d3
- X bne.s 8$
- X move.l a3,a0 ; if error, go to where we started from
- X8$:
- X pull a1-a3/d1-d5
- X rts
- X
- X* This routine gets number from (a0)+ to d0.w
- X
- XGetNum:
- X push d1/d2/a1
- X move.l a0,a1
- X moveq #FALSE,d2 ; no valid number yet
- X moveq #0,d0
- X2$:
- X move.b (a0)+,d1
- X cmp.b #'0',d1
- X blo.s 1$
- X cmp.b #'9',d1
- X bhi.s 1$
- X
- X sub.b #'0',d1
- X ext.w d1
- X mulu #10,d0
- X add.w d1,d0
- X moveq #TRUE,d2 ; valid number
- X bra.s 2$
- X
- X1$:
- X subq.l #1,a0
- X bsr.s SkipBlk
- X
- X tst.w d2 ; invalid?
- X bne.s 3$
- X move.l a1,a0 ; if error, get back where to we started from
- X3$:
- X pull d1/d2/a1
- X rts
- X
- X* This will skip all spaces and tabs.
- X
- XSkipBlk:
- X push d0
- X1$:
- X move.b (a0)+,d0
- X cmp.b #' ',d0
- X beq.s 1$
- X subq.l #1,a0
- X pull d0
- X rts
- X
- X* A subroutine for each of the options
- Xopt_x: bsr GetFixed
- X beq.s opt_xx
- X move.l d0,CurrentX
- X moveq #TRUE,d0
- X rts
- Xopt_xx
- X* This is just -x meaning exit when drawn.
- X clr.b inter
- X moveq #TRUE,d0
- X rts
- X
- Xopt_y: bsr GetFixed
- X beq.s 1$
- X move.l d0,CurrentY
- X moveq #TRUE,d0
- X1$: rts
- X
- X* This option is a very special one (internally) because it uses
- X* still one different number format (scaled by 2^16).
- X* This is converted to actual mb_dx and mb_dy values later...
- Xopt_m: bsr.s GetMagnify
- X beq.s opt_mm
- X move.l d0,Magnify
- X moveq #TRUE,d0
- X rts
- Xopt_mm
- X* This is only -m meaning mandelbrot sets
- X bclr.b #MBB_JULIA,mb_flags(a4)
- X moveq #TRUE,d0
- X rts
- X
- XGetMagnify:
- X push a1-a2/d1-d2
- X move.l a1,a2
- X bsr GetNum
- X swap d0 ; integer part go to high 16 bits
- X cmp.b #'.',(a0)+
- X bne.s m_space ; number had ONLY integer part
- X moveq #0,d1 ; collect number here
- X moveq #0,d2 ; clear extra bits
- X clr.w d0
- Xm_find_end:
- X move.b (a0)+,d2
- X addq.w #1,d0 ; low word has a temporary role as counter
- X cmp.b #'0',d2
- X blo.s m_end_found
- X cmp.b #'9',d2
- X bls.s m_find_end
- Xm_end_found:
- X lea -1(a0),a1
- Xm_loop:
- X subq.w #1,d0
- X beq.s m_got_it
- X move.b -(a1),d2
- X sub.b #'0',d2
- X swap d1
- X move.w d2,d1
- X swap d1
- X divu #10,d1
- X bra.s m_loop
- Xm_got_it:
- X move.w d1,d0
- X
- Xm_space:
- X subq.l #1,a0
- X bsr SkipBlk
- X cmp.l #$001d0000,d0 ; greater than 2^29?
- X bhi.s m_error
- X moveq #TRUE,d1
- X bra.s m_exit
- Xm_error:
- X moveq #FALSE,d0
- X move.l a2,a1
- Xm_exit: pull a1-a2/d1-d2
- X rts
- X
- X
- Xopt_i: bsr GetNum
- X beq.s 1$
- X move.w d0,mb_i(a4)
- X moveq #TRUE,d0
- X1$: rts
- X
- X
- Xopt_l: bclr.b #MBB_AUTOPREC,mb_flags(a4)
- X bclr.b #MBB_HIGH,mb_flags(a4)
- X moveq #TRUE,d0
- X rts
- X
- Xopt_h: bclr.b #MBB_AUTOPREC,mb_flags(a4)
- X bset.b #MBB_HIGH,mb_flags(a4)
- X moveq #TRUE,d0
- X rts
- X
- Xopt_a: bset.b #MBB_AUTOPREC,mb_flags(a4)
- X moveq #TRUE,d0
- X rts
- X
- X
- Xopt_c: bclr.b #MBB_AUTOCRAWL,mb_flags(a4)
- X bset.b #MBB_CRAWL,mb_flags(a4)
- X moveq #TRUE,d0
- X rts
- X
- Xopt_w: bclr.b #MBB_AUTOCRAWL,mb_flags(a4)
- X bclr.b #MBB_CRAWL,mb_flags(a4)
- X moveq #TRUE,d0
- X rts
- X
- Xopt_p: bset.b #MBB_AUTOCRAWL,mb_flags(a4)
- X moveq #TRUE,d0
- X rts
- X
- Xopt_g: move.b #TRUE,inter
- X rts
- X
- X
- Xopt_j: move.b (a0)+,d0
- X toupper d0
- X
- X cmp.b #'X',d0
- X bne.s j_no_x
- Xopt_jx ; WB options enter this routine here
- X bsr GetFixed
- X beq.s 1$
- X move.l d0,mb_jx(a4)
- X moveq #TRUE,d0
- X1$: rts
- X
- Xj_no_x: cmp.b #'Y',d0
- X bne.s j_no_y
- Xopt_jy ; WB entry point
- X bsr GetFixed
- X beq.s 1$
- X move.l d0,mb_jy(a4)
- X moveq #TRUE,d0
- X1$: rts
- X
- X
- Xj_no_y
- X* This is just -j meaning julia sets
- X subq.l #1,a0
- Xopt_jj ; WB entry
- X bset.b #MBB_JULIA,mb_flags(a4)
- X moveq #TRUE,d0
- X rts
- X
- Xopt_s
- X lea NameBuffer,a1
- Xs_endstr
- X move.b (a0)+,d0
- X beq.s s_over
- X cmp.b #' ',d0
- X beq.s s_over
- X move.b d0,(a1)+
- X bra.s s_endstr
- Xs_over
- X subq.l #1,a0
- X clr.b (a1)
- X move.l a1,NameEnd
- X bsr SkipBlk
- X move.b #TRUE,d0
- X move.b d0,saveit
- X rts
- X
- X
- X* For WB use, e.g. FLAGS=xc\0
- Xopt_flags
- X move.b (a0)+,d0
- X beq.s no_more_flags
- X toupper d0
- X
- X* This will return use in this routine.
- X pea opt_flags
- X cmp.b #'L',d0
- X beq opt_l
- X cmp.b #'H',d0
- X beq opt_h
- X cmp.b #'A',d0
- X beq opt_a
- X cmp.b #'C',d0
- X beq opt_c
- X cmp.b #'W',d0
- X beq opt_w
- X cmp.b #'P',d0
- X beq opt_p
- X cmp.b #'G',d0
- X beq opt_g
- X cmp.b #'J',d0
- X beq opt_jj ; not opt_j
- X cmp.b #'M',d0
- X beq opt_mm ; not opt_m
- X cmp.b #'X',d0
- X beq opt_xx ; not opt_x
- X* Wrong option!
- X addq.l #4,a7
- X moveq #FALSE,d0
- X rts
- Xno_more_flags
- X moveq #TRUE,d0
- X rts
- X
- XSavePicture:
- X lea NameBuffer,a0
- X move.l a0,d2
- X
- X move.l NameEnd,a0
- X move.w Counter,d0
- X beq.s first_time
- X* When 2nd etc. file saved, use a running number as an identifier
- X bsr toInt
- X clr.b (a0) ; 0 terminates string
- Xfirst_time:
- X addq.w #1,Counter
- X
- X lea _IffLib,a1
- X moveq #0,d0
- X Base Exec
- X Call OpenLibrary
- X tst.l d0
- X beq.s noifflib
- X move.l d0,a6
- X
- X move.l MyScreen,a0
- X move.l sc_ViewPort+vp_ColorMap(a0),a2
- X move.l cm_ColorTable(a2),a2 ; colortable
- X move.l sc_RastPort+rp_BitMap(a0),a1 ; bitmap
- X move.l d2,a0 ; filename
- X
- X move.w mb_x1(a4),d1
- X move.w mb_y1(a4),d2
- X move.w mb_x2(a4),d3
- X move.w mb_y2(a4),d4
- X
- X lsr.w #3,d1 ; no of BYTES
- X add.w #7,d3
- X lsr.w #3,d3
- X
- X sub.w d1,d3
- X sub.w d2,d4
- X addq.w #1,d3 ; width and heigth
- X addq.w #1,d4
- X
- X moveq #1,d0 ; run-length compression
- X
- X jsr SaveClip(a6)
- X move.l d0,d2
- X
- X move.l a6,a1
- X Base Exec
- X Call CloseLibrary
- X
- X tst.l d2
- X bne.s exit_save
- X move.b #ERROR_ifflib,error
- X bra.s exit_save
- Xnoifflib:
- X move.b #ERROR_noifflib,error
- Xexit_save:
- X rts
- X
- X SECTION data,DATA
- X* First elements form $20000000 00000000 (represents 1)
- X* then 1/10, 1/100 etc.
- XNumberHi:
- X dc.l $20000000,$03333333,$0051EB85,$00083126
- X dc.l $0000D1B7,$000014F8,$00000218,$00000035
- X dc.l $00000005,$00000000,$00000000,$00000000
- X dc.l $00000000,$00000000,$00000000,$00000000
- XNumberLo:
- X dc.l $00000000,$33333333,$1EB851EB,$E978D4FD
- X dc.l $1758E219,$B588E368,$DEF416BD,$AFE53579
- X dc.l $5E63B88C,$89705F41,$0DBE6FEC,$015FD7FE
- X dc.l $00232F33,$000384B8,$00005A12,$00000901
- X
- X* Still one table. This time: 2^(-1/2) , 2^(-1/4) ... times $10000.
- XNumberP:
- X dc.w $b505,$d745,$eac1,$f525,$fa84,$fd3e,$fe9e,$ff4f
- X dc.w $ffa7,$ffd4,$ffea,$fff5,$fffa,$fffd,$ffff,$ffff
- X* Inverse of former: 2^(1/2), 2^(1/4) etc.
- X* Implied highest "1" has been deleted.
- X* (Example: 2^(1/2) = sqrt(2) = 1.4142 x $10000 = $16a0a -> $6a0a)
- XNumberL:
- X dc.w $6A0A,$3070,$172C,$0B56,$059B,$02CA,$0164,$00B2
- X dc.w $0059,$002C,$0016,$000B,$0006,$0003,$0001,$0001
- X
- X
- XColors:
- X ifeq DEPTH-5
- X dc.w $888,$000
- X dc.w $f00,$f30,$f60,$f90,$fc0,$ff0,$cf0,$9f0,$6f0,$3f0
- X dc.w $0f0,$0f3,$0f6,$0f9,$0fc,$0ff,$0cf,$09f,$06f,$03f
- X dc.w $00f,$30f,$60f,$90f,$c0f,$f0f,$f0c,$f09,$f06,$f03
- X endc
- X ifeq DEPTH-4
- X dc.w $888,$000
- X dc.w $f00,$f80,$ff0,$8f0
- X dc.w $0f0,$0f6,$0fc,$0cf,$06f
- X dc.w $00f,$60f,$c0f,$f0c,$f06
- X endc
- X ifeq DEPTH-3
- X dc.w $888,$000,$f00,$ff0,$0f0,$0ff,$00f,$f0f
- X endc
- X ifeq DEPTH-2
- X dc.w $888,$000,$f00,$00f
- X endc
- XMyNewScreen:
- X dc.w 0,0 ; offsets
- X dc.w XSIZE,YSIZE ; size x * y
- X dc.w DEPTH ; planes
- X dc.b 1,2 ; default pens
- X dc.w VIEWMODE
- X dc.w CUSTOMSCREEN
- X dc.l 0,ScreenTitle,0 ; font,title,gadgets
- X
- XMyNewWindow1:
- X dc.w 0,0
- X dc.w XSIZE,YSIZE ; width, heigth
- X dc.b 1,2 ; pens
- X dc.l IDCMP1 ; IDCMP
- X dc.l FLAGS1
- X dc.l 0,0,0 ; gadgets, checkmark, title
- XInsertScreen1:
- X ds.l 1 ; screen (to be inserted later)
- X dc.l 0 ; bitmap
- X dc.w -1,-1,-1,-1 ; min/max size
- X dc.w CUSTOMSCREEN ; screen type
- X
- XMyNewWindow2:
- X dc.w WINX,WINY ; place (to be modified later)
- X dc.w WINW,WINH ; width, heigth
- X dc.b 1,2 ; pens
- X dc.l IDCMP2 ; IDCMP
- X dc.l FLAGS2
- X dc.l XGadget ; ... gadgets ... (lots of them!)
- X dc.l 0,0 ; checkmark, title
- XInsertScreen2:
- X ds.l 1 ; screen (to be inserted later)
- X dc.l 0 ; bitmap
- X dc.w -1,-1,-1,-1 ; min/max size
- X dc.w CUSTOMSCREEN ; screen type
- X
- XuniqueID SET 0
- XMakeID macro
- X\1 EQU uniqueID
- XuniqueID SET uniqueID+1
- X endm
- X
- X MakeID GAD_X
- X MakeID GAD_Y
- X MakeID GAD_M
- X MakeID GAD_Z
- X MakeID GAD_I
- X MakeID GAD_ZOOM
- X MakeID GAD_DRAW
- X MakeID GAD_RESET
- X MakeID GAD_MANDEL
- X MakeID GAD_JULIA
- X MakeID GAD_QUIT
- XMINUS EQU $8000
- XSTRING EQU $4000
- XZOOMTYPE EQU $2000
- XSETTYPE EQU $1000
- XIDMASK EQU $8fff ; so as not to mask sign
- X
- XXGadget:
- X dc.l YGadget ; link to next
- X dc.w 39,13,104,8 ; place & size
- X dc.w GADGHCOMP
- X dc.w RELVERIFY|GADGIMMEDIATE
- X dc.w STRGADGET
- X dc.l XYBorder ; image for gadget
- X dc.l 0
- X dc.l XText
- X dc.l 0 ; MutualExclude
- X dc.l XString ; specialinfo
- X dc.w STRING|GAD_X ; ID
- X dc.l 0
- XXString:
- X dc.l XBuffer
- X dc.l 0
- X dc.w 0
- X dc.w 13
- X dc.w 0
- X dc.w 0,0,0,0,0
- X dc.l 0
- X dc.l 0,0
- XXText:
- X dc.b 1,2 ; pens
- X dc.b RP_JAM1,0 ; drawmodes
- X dc.w -10,0 ; offsets
- X dc.l 0 ; default font
- X dc.l XLetter ; (yeah, just one letter)
- X dc.l 0 ; no more text
- XYGadget:
- X dc.l YPLUSGadget ; the next one
- X dc.w 39,26,104,8 ; place & size
- X dc.w GADGHCOMP
- X dc.w RELVERIFY|GADGIMMEDIATE
- X dc.w STRGADGET
- X dc.l XYBorder
- X dc.l 0
- X dc.l YText
- X dc.l 0
- X dc.l YString ; specialinfo
- X dc.w STRING|GAD_Y ; ID
- X dc.l 0
- XYString:
- X dc.l YBuffer
- X dc.l 0
- X dc.w 0
- X dc.w 13
- X dc.w 0
- X dc.w 0,0,0,0,0
- X dc.l 0
- X dc.l 0,0
- XYText:
- X dc.b 1,2 ; pens
- X dc.b RP_JAM1,0 ; drawmodes
- X dc.w -10,0 ; offsets
- X dc.l 0 ; default font
- X dc.l YLetter ; (yeah, just one letter)
- X dc.l 0 ; no more text
- XXYBorder:
- X dc.w -2,-2 ; place
- X dc.b 1,0 ; pens
- X dc.b RP_JAM1
- X dc.b 5 ; # of pairs
- X dc.l XYPairs ; the actual data
- X dc.l 0
- XXYPairs:
- X dc.w 0,0
- X dc.w 107,0
- X dc.w 107,11
- X dc.w 0,11
- X dc.w 0,0
- XYPLUSGadget:
- X dc.l YMINUSGadget ; and the next one.
- X dc.w 10,11,11,6 ; place & size
- X dc.w GADGHCOMP|GADGIMAGE
- X dc.w RELVERIFY|GADGIMMEDIATE
- X dc.w BOOLGADGET
- X dc.l UPimage
- X dc.l 0,0,0
- X dc.l 0 ; specialinfo
- X dc.w GAD_Y ; ID
- X dc.l 0
- XYMINUSGadget:
- X dc.l XMINUSGadget ; and the next one.
- X dc.w 10,30,11,6 ; place & size
- X dc.w GADGHCOMP|GADGIMAGE
- X dc.w RELVERIFY|GADGIMMEDIATE
- X dc.w BOOLGADGET
- X dc.l DOWNimage
- X dc.l 0,0,0
- X dc.l 0 ; specialinfo
- X dc.w GAD_Y|MINUS ; ID
- X dc.l 0
- XXMINUSGadget:
- X dc.l XPLUSGadget ; and the next one.
- X dc.w 3,18,6,11 ; place & size
- X dc.w GADGHCOMP|GADGIMAGE
- X dc.w RELVERIFY|GADGIMMEDIATE
- X dc.w BOOLGADGET
- X dc.l LEFTimage
- X dc.l 0,0,0
- X dc.l 0 ; specialinfo
- X dc.w GAD_X|MINUS ; ID
- X dc.l 0
- XXPLUSGadget:
- X dc.l MGadget ; and the next one.
- X dc.w 22,18,6,11 ; place & size
- X dc.w GADGHCOMP|GADGIMAGE
- X dc.w RELVERIFY|GADGIMMEDIATE
- X dc.w BOOLGADGET
- X dc.l RIGHTimage
- X dc.l 0,0,0
- X dc.l 0 ; specialinfo
- X dc.w GAD_X ; ID
- X dc.l 0
- XMGadget:
- X dc.l MPLUSGadget ; more to come...
- X dc.w 23,42,40,8 ; place & size
- X dc.w GADGHCOMP
- X dc.w RELVERIFY|GADGIMMEDIATE
- X dc.w STRGADGET
- X dc.l MBorder
- X dc.l 0
- X dc.l MText
- X dc.l 0
- X dc.l MString ; specialinfo
- X dc.w STRING|GAD_M ; ID
- X dc.l 0
- XMString:
- X dc.l MBuffer
- X dc.l 0
- X dc.w 0
- X dc.w 9
- X dc.w 0
- X dc.w 0,0,0,0,0
- X dc.l 0
- X dc.l 0,0
- XMText:
- X dc.b 1,2 ; pens
- X dc.b RP_JAM1,0 ; drawmodes
- X dc.w -18,0 ; offsets
- X dc.l 0 ; default font
- X dc.l MLetter ; (yeah, just one letter)
- X dc.l 0 ; no more text
- XMBorder:
- X dc.w -2,-2 ; place
- X dc.b 1,0 ; pens
- X dc.b RP_JAM1
- X dc.b 5 ; # of pairs
- X dc.l MPairs ; the actual data
- X dc.l 0
- XMPairs:
- X dc.w 0,0
- X dc.w 43,0
- X dc.w 43,11
- END_OF_FILE
- if test 26047 -ne `wc -c <'source/gui.asm.ac'`; then
- echo shar: \"'source/gui.asm.ac'\" unpacked with wrong size!
- fi
- # end of 'source/gui.asm.ac'
- fi
- echo shar: End of archive 2 \(of 4\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 4 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 4 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
- Mail comments to the moderator at <amiga-request@uunet.uu.net>.
- Post requests for sources, and general discussion to comp.sys.amiga.misc.
-